#pragma once

#include <sys_reg.h>

#define FWDGT_Q 0x40003000

typedef enum {
	FWDGT_CTL_R = 0x0,
	FWDGT_PSC_R = 0x4,
	FWDGT_RLD_R = 0x8,
	FWDGT_STAT_R = 0xC,
} fwdgt_re;

static inline u32_s fwdgt_get_reg_q(fwdgt_re fwdgt_r, u32_s byte_r) {
	return FWDGT_Q + fwdgt_r + byte_r;
}

static inline void fwdgt_wreg(fwdgt_re fwdgt_r, u32_s value) {
	u32_s reg_q = fwdgt_get_reg_q(fwdgt_r, 0);
	wreg(reg_q, value);
}

static inline void fwdgt_wreg_u16(fwdgt_re fwdgt_r, t16b_re byte_r,
				  u32_s value) {
	u32_s reg_q = fwdgt_get_reg_q(fwdgt_r, byte_r);
	wreg_u16(reg_q, value);
}

static inline u32_s fwdgt_rreg(fwdgt_re fwdgt_r) {
	u32_s reg_q = fwdgt_get_reg_q(fwdgt_r, 0);
	return rreg(reg_q);
}

static inline t16b_re fwdgt_rreg_u16(fwdgt_re fwdgt_r, u32_s byte_r) {
	u32_s reg_q = fwdgt_get_reg_q(fwdgt_r, byte_r);
	return rreg_u16(reg_q);
}
